#pragma once
#include "Windows.h"

class CQueue {
public:
	struct ELEMENT {
		int m_nThreadNum;
		int m_nRequestNum;
	};
	typedef ELEMENT* PELEMENT;

private:
	struct INNER_ELEMENT {
		int m_nStamp;
		ELEMENT m_element;
	};
	typedef INNER_ELEMENT* PINNER_ELEMENT;

private:
	PINNER_ELEMENT m_pElements;
	int m_nMaxElement;
	int m_nCurrentStamp;
	


private:
	int GetFreeSlot();
	int GetNextSlot(int nThreeNum);

public:
	CQueue(int nMaxElements);
	~CQueue();
	BOOL IsFull();
	BOOL IsEmpty(int nThreadNum);
	void AddElement(ELEMENT e);
	BOOL GetNewElement(int nThreadNum, ELEMENT& e);
};

